import request from '../utils/request';

/**
 * 通过项目Id查询任务分页信息
 * @param {*} params
 */
const getPage = params => request({
  url: `/v1/project/task/${params.id}/page`,
  method: 'get',
  params
});

/**
 * 新增任务
 * @param {*} data
 */
const create = data => request({
  url: `/v1/project/task`,
  method: 'post',
  data: data
});

/**
 * 指派任务
 * @param {*} data
 */
const accept = data => request({
  url: `/v1/project/task/${data.id}/accept`,
  method: 'put',
  data: data
});

/**
 * 修改任务状态
 * @param {*} data
 */
const status = data => request({
  url: `/v1/project/task/${data.id}/status`,
  method: 'put',
  data: data
});
/**
 * 获取任务
 * @param {*} params
 */
const getById = params => request({
  url: `/v1/project/task/${params.id}`,
  method: 'get',
  data: params
});
/**
 * 更新任务
 * @param {*} data
 */
const update = data => request({
  url: `/v1/project/task/${data.id}`,
  method: 'put',
  data: data
});

/**
 * 更新任务状态
 * @param {*} data
 */
const updateStatus = data => request({
  url: `/v1/project/task/${data.id}/status`,
  method: 'put',
  data: data
});

/**
 * 新增关系
 * @param {*} data
 */
const createRelated = data => request({
  url: `/v1/project/task/related`,
  method: 'post',
  data: data
});
/**
 * 新增评论
 * @param {*} data
 */
const createComments = data => request({
  url: `/v1/project/task/comment`,
  method: 'post',
  data: data
});
/**
 * 获取评论
 * @param {*} params
 */
const getComments = params => request({
  url: `/v1/project/task/${params.id}/comment/list`,
  method: 'get'
});

/**
 * 获取人
 * @param {*} params
 */
const getPersonByAll = params => request({
  url: `/v1/project/task/${params.id}/resource/list`,
  method: 'get',
  params
});

/**
 * 改变顺序
 * @param {*} data
 */
const getModifyOrder = data => request({
  url: `/v1/project/task/${data.id}/order`,
  method: 'put',
  data
});

export default {
  getPage,
  create,
  accept,
  status,
  getById,
  update,
  updateStatus,
  createRelated,
  createComments,
  getComments,
  getPersonByAll,
  getModifyOrder
}
